package zsk;

import java.util.HashMap;
import java.util.Map;

public abstract class UTF8 {
	
	protected static HashMap<String, String> CHAR_MAP;

	public static String changeHTMLtoUTF8(String htmlToChange) {
		
		UTF8.CHAR_MAP = new HashMap<String, String>();
		
		// fill hasmap
		
		CHAR_MAP.put("&#32;"," "); 
		CHAR_MAP.put("&#160;"," ");
		CHAR_MAP.put("&nbsp;"," ");
		CHAR_MAP.put("&#33;","!"); 
		CHAR_MAP.put("&#34;","\"");
		CHAR_MAP.put("&quot;","\"");
		CHAR_MAP.put("&#35;","#"); 
		CHAR_MAP.put("&#36;","$"); 
		CHAR_MAP.put("&#37;","%"); 
		CHAR_MAP.put("&#38;","&"); 
		CHAR_MAP.put("&#39;","'"); 
		CHAR_MAP.put("&#40;","("); 
		CHAR_MAP.put("&#41;",")"); 
		CHAR_MAP.put("&#42;","*"); 
		CHAR_MAP.put("&#43;","+"); 
		CHAR_MAP.put("&#44;",","); 
		CHAR_MAP.put("&#45;","-"); 
		CHAR_MAP.put("&#46;","."); 
		CHAR_MAP.put("&#47;","/"); 
		CHAR_MAP.put("&#48;","0"); 
		CHAR_MAP.put("&#49;","1"); 
		CHAR_MAP.put("&#50;","2"); 
		CHAR_MAP.put("&#51;","3"); 
		CHAR_MAP.put("&#52;","4"); 
		CHAR_MAP.put("&#53;","5"); 
		CHAR_MAP.put("&#54;","6"); 
		CHAR_MAP.put("&#55;","7"); 
		CHAR_MAP.put("&#56;","8"); 
		CHAR_MAP.put("&#57;","9"); 
		CHAR_MAP.put("&#58;",":"); 
		CHAR_MAP.put("&#59;",";"); 
		CHAR_MAP.put("&#60;","<");
		CHAR_MAP.put("&lt;","<");
		CHAR_MAP.put("&#61;","="); 
		CHAR_MAP.put("&#62;",">");
		CHAR_MAP.put("&gt;",">");
		CHAR_MAP.put("&#63;","?"); 
		CHAR_MAP.put("&#64;","@"); 
		CHAR_MAP.put("&#65;","A"); 
		CHAR_MAP.put("&#66;","B"); 
		CHAR_MAP.put("&#67;","C"); 
		CHAR_MAP.put("&#68;","D"); 
		CHAR_MAP.put("&#69;","E"); 
		CHAR_MAP.put("&#70;","F"); 
		CHAR_MAP.put("&#71;","G"); 
		CHAR_MAP.put("&#72;","H"); 
		CHAR_MAP.put("&#73;","I"); 
		CHAR_MAP.put("&#74;","J"); 
		CHAR_MAP.put("&#75;","K"); 
		CHAR_MAP.put("&#76;","L"); 
		CHAR_MAP.put("&#77;","M"); 
		CHAR_MAP.put("&#78;","N"); 
		CHAR_MAP.put("&#79;","O"); 
		CHAR_MAP.put("&#80;","P"); 
		CHAR_MAP.put("&#81;","Q"); 
		CHAR_MAP.put("&#82;","R"); 
		CHAR_MAP.put("&#83;","S"); 
		CHAR_MAP.put("&#84;","T"); 
		CHAR_MAP.put("&#85;","U"); 
		CHAR_MAP.put("&#86;","V"); 
		CHAR_MAP.put("&#87;","W"); 
		CHAR_MAP.put("&#88;","X"); 
		CHAR_MAP.put("&#89;","Y"); 
		CHAR_MAP.put("&#90;","Z"); 
		CHAR_MAP.put("&#91;","["); 
		CHAR_MAP.put("&#92;","\\"); 
		CHAR_MAP.put("&#93;","]"); 
		CHAR_MAP.put("&#94;","^"); 
		CHAR_MAP.put("&#95;","_"); 
		CHAR_MAP.put("&#96;","`"); 
		CHAR_MAP.put("&#97;","a"); 
		CHAR_MAP.put("&#98;","b"); 
		CHAR_MAP.put("&#99;","c"); 
		CHAR_MAP.put("&#100;","d"); 
		CHAR_MAP.put("&#101;","e"); 
		CHAR_MAP.put("&#102;","f"); 
		CHAR_MAP.put("&#103;","g"); 
		CHAR_MAP.put("&#104;","h"); 
		CHAR_MAP.put("&#105;","i"); 
		CHAR_MAP.put("&#106;","j"); 
		CHAR_MAP.put("&#107;","k"); 
		CHAR_MAP.put("&#108;","l"); 
		CHAR_MAP.put("&#109;","m"); 
		CHAR_MAP.put("&#110;","n"); 
		CHAR_MAP.put("&#111;","o"); 
		CHAR_MAP.put("&#112;","p"); 
		CHAR_MAP.put("&#113;","q"); 
		CHAR_MAP.put("&#114;","r"); 
		CHAR_MAP.put("&#115;","s"); 
		CHAR_MAP.put("&#116;","t"); 
		CHAR_MAP.put("&#117;","u"); 
		CHAR_MAP.put("&#118;","v"); 
		CHAR_MAP.put("&#119;","w"); 
		CHAR_MAP.put("&#120;","x"); 
		CHAR_MAP.put("&#121;","y"); 
		CHAR_MAP.put("&#122;","z"); 
		CHAR_MAP.put("&#123;","{"); 
		CHAR_MAP.put("&#124;","|"); 
		CHAR_MAP.put("&#125;","}"); 
		CHAR_MAP.put("&#126;","~"); 
		CHAR_MAP.put("&#161;","Â¡");
		CHAR_MAP.put("&iexcl;","Â¡");
		CHAR_MAP.put("&#162;","Â¢");
		CHAR_MAP.put("&cent;","Â¢");
		CHAR_MAP.put("&#163;","Â£");
		CHAR_MAP.put("&pound;","Â£");
		CHAR_MAP.put("&#164;","Â¤");
		CHAR_MAP.put("&curren;","Â¤");
		CHAR_MAP.put("&#165;","Â¥");
		CHAR_MAP.put("&yen;","Â¥");
		CHAR_MAP.put("&#166;","Â¦");
		CHAR_MAP.put("&brvbar;","Â¦");
		CHAR_MAP.put("&#167;","Â§");
		CHAR_MAP.put("&sect;","Â§");
		CHAR_MAP.put("&#168;","Â¨");
		CHAR_MAP.put("&uml;","Â¨");
		CHAR_MAP.put("&#169;","Â©");
		CHAR_MAP.put("&copy;","Â©");
		CHAR_MAP.put("&#170;","Âª");
		CHAR_MAP.put("&ordf;","Âª");
		CHAR_MAP.put("&#171;","Â«");
		CHAR_MAP.put("&laquo;","Â«");
		CHAR_MAP.put("&#172;","Â¬");
		CHAR_MAP.put("&not;","Â¬");
		CHAR_MAP.put("&#173;","Â­");
		CHAR_MAP.put("&shy;","Â­");
		CHAR_MAP.put("&#174;","Â®");
		CHAR_MAP.put("&reg;","Â®");
		CHAR_MAP.put("&#175;","Â¯");
		CHAR_MAP.put("&macr;","Â¯");
		CHAR_MAP.put("&#176;","Â°");
		CHAR_MAP.put("&deg;","Â°");
		CHAR_MAP.put("&#177;","Â±");
		CHAR_MAP.put("&plusmn;","Â±");
		CHAR_MAP.put("&#178;","Â²");
		CHAR_MAP.put("&sup2;","Â²");
		CHAR_MAP.put("&#179;","Â³");
		CHAR_MAP.put("&sup3;","Â³");
		CHAR_MAP.put("&#180;","Â´");
		CHAR_MAP.put("&acute;","Â´");
		CHAR_MAP.put("&#181;","Âµ");
		CHAR_MAP.put("&micro;","Âµ");
		CHAR_MAP.put("&#182;","Â¶");
		CHAR_MAP.put("&para;","Â¶");
		CHAR_MAP.put("&#183;","Â·");
		CHAR_MAP.put("&middot;","Â·");
		CHAR_MAP.put("&#184;","Â¸");
		CHAR_MAP.put("&cedil;","Â¸");
		CHAR_MAP.put("&#185;","Â¹");
		CHAR_MAP.put("&sup1;","Â¹");
		CHAR_MAP.put("&#186;","Âº");
		CHAR_MAP.put("&ordm;","Âº");
		CHAR_MAP.put("&#187;","Â»");
		CHAR_MAP.put("&raquo;","Â»");
		CHAR_MAP.put("&#188;","Â¼");
		CHAR_MAP.put("&frac14;","Â¼");
		CHAR_MAP.put("&#189;","Â½");
		CHAR_MAP.put("&frac12;","Â½");
		CHAR_MAP.put("&#190;","Â¾");
		CHAR_MAP.put("&frac34;","Â¾");
		CHAR_MAP.put("&#191;","Â¿");
		CHAR_MAP.put("&iquest;","Â¿");
		CHAR_MAP.put("&#192;","Ã€");
		CHAR_MAP.put("&Agrave;","Ã€");
		CHAR_MAP.put("&#193;","Ã�");
		CHAR_MAP.put("&Aacute;","Ã�");
		CHAR_MAP.put("&#194;","Ã‚");
		CHAR_MAP.put("&Acirc;","Ã‚");
		CHAR_MAP.put("&#195;","Ãƒ");
		CHAR_MAP.put("&Atilde;","Ãƒ");
		CHAR_MAP.put("&#196;","Ã„");
		CHAR_MAP.put("&Auml;","Ã„");
		CHAR_MAP.put("&#197;","Ã…");
		CHAR_MAP.put("&Aring;","Ã…");
		CHAR_MAP.put("&#198;","Ã†");
		CHAR_MAP.put("&AElig;","Ã†");
		CHAR_MAP.put("&#199;","Ã‡");
		CHAR_MAP.put("&Ccedil;","Ã‡");
		CHAR_MAP.put("&#200;","Ãˆ");
		CHAR_MAP.put("&Egrave;","Ãˆ");
		CHAR_MAP.put("&#201;","Ã‰");
		CHAR_MAP.put("&Eacute;","Ã‰");
		CHAR_MAP.put("&#202;","ÃŠ");
		CHAR_MAP.put("&Ecirc;","ÃŠ");
		CHAR_MAP.put("&#203;","Ã‹");
		CHAR_MAP.put("&Euml;","Ã‹");
		CHAR_MAP.put("&#204;","ÃŒ");
		CHAR_MAP.put("&Igrave;","ÃŒ");
		CHAR_MAP.put("&#205;","Ã�");
		CHAR_MAP.put("&Iacute;","Ã�");
		CHAR_MAP.put("&#206;","ÃŽ");
		CHAR_MAP.put("&Icirc;","ÃŽ");
		CHAR_MAP.put("&#207;","Ã�");
		CHAR_MAP.put("&Iuml;","Ã�");
		CHAR_MAP.put("&#208;","Ã�");
		CHAR_MAP.put("&ETH;","Ã�");
		CHAR_MAP.put("&#209;","Ã‘");
		CHAR_MAP.put("&Ntilde;","Ã‘");
		CHAR_MAP.put("&#210;","Ã’");
		CHAR_MAP.put("&Ograve;","Ã’");
		CHAR_MAP.put("&#211;","Ã“");
		CHAR_MAP.put("&Oacute;","Ã“");
		CHAR_MAP.put("&#212;","Ã”");
		CHAR_MAP.put("&Ocirc;","Ã”");
		CHAR_MAP.put("&#213;","Ã•");
		CHAR_MAP.put("&Otilde;","Ã•");
		CHAR_MAP.put("&#214;","Ã–");
		CHAR_MAP.put("&Ouml;","Ã–");
		CHAR_MAP.put("&#215;","Ã—");
		CHAR_MAP.put("&times;","Ã—");
		CHAR_MAP.put("&#216;","Ã˜");
		CHAR_MAP.put("&Oslash;","Ã˜");
		CHAR_MAP.put("&#217;","Ã™");
		CHAR_MAP.put("&Ugrave;","Ã™");
		CHAR_MAP.put("&#218;","Ãš");
		CHAR_MAP.put("&Uacute;","Ãš");
		CHAR_MAP.put("&#219;","Ã›");
		CHAR_MAP.put("&Ucirc;","Ã›");
		CHAR_MAP.put("&#220;","Ãœ");
		CHAR_MAP.put("&Uuml;","Ãœ");
		CHAR_MAP.put("&#221;","Ã�");
		CHAR_MAP.put("&Yacute;","Ã�");
		CHAR_MAP.put("&#222;","Ãž");
		CHAR_MAP.put("&THORN;","Ãž");
		CHAR_MAP.put("&#223;","ÃŸ");
		CHAR_MAP.put("&szlig;","ÃŸ");
		CHAR_MAP.put("&#224;","Ã ");
		CHAR_MAP.put("&agrave;","Ã ");
		CHAR_MAP.put("&#225;","Ã¡");
		CHAR_MAP.put("&aacute;","Ã¡");
		CHAR_MAP.put("&#226;","Ã¢");
		CHAR_MAP.put("&acirc;","Ã¢");
		CHAR_MAP.put("&#227;","Ã£");
		CHAR_MAP.put("&atilde;","Ã£");
		CHAR_MAP.put("&#228;","Ã¤");
		CHAR_MAP.put("&auml;","Ã¤");
		CHAR_MAP.put("&#229;","Ã¥");
		CHAR_MAP.put("&aring;","Ã¥");
		CHAR_MAP.put("&#230;","Ã¦");
		CHAR_MAP.put("&aelig;","Ã¦");
		CHAR_MAP.put("&#231;","Ã§");
		CHAR_MAP.put("&ccedil;","Ã§");
		CHAR_MAP.put("&#232;","Ã¨");
		CHAR_MAP.put("&egrave;","Ã¨");
		CHAR_MAP.put("&#233;","Ã©");
		CHAR_MAP.put("&eacute;","Ã©");
		CHAR_MAP.put("&#234;","Ãª");
		CHAR_MAP.put("&ecirc;","Ãª");
		CHAR_MAP.put("&#235;","Ã«");
		CHAR_MAP.put("&euml;","Ã«");
		CHAR_MAP.put("&#236;","Ã¬");
		CHAR_MAP.put("&igrave;","Ã¬");
		CHAR_MAP.put("&#237;","Ã­");
		CHAR_MAP.put("&iacute;","Ã­");
		CHAR_MAP.put("&#238;","Ã®");
		CHAR_MAP.put("&icirc;","Ã®");
		CHAR_MAP.put("&#239;","Ã¯");
		CHAR_MAP.put("&iuml;","Ã¯");
		CHAR_MAP.put("&#240;","Ã°");
		CHAR_MAP.put("&eth;","Ã°");
		CHAR_MAP.put("&#241;","Ã±");
		CHAR_MAP.put("&ntilde;","Ã±");
		CHAR_MAP.put("&#242;","Ã²");
		CHAR_MAP.put("&ograve;","Ã²");
		CHAR_MAP.put("&#243;","Ã³");
		CHAR_MAP.put("&oacute;","Ã³");
		CHAR_MAP.put("&#244;","Ã´");
		CHAR_MAP.put("&ocirc;","Ã´");
		CHAR_MAP.put("&#245;","Ãµ");
		CHAR_MAP.put("&otilde;","Ãµ");
		CHAR_MAP.put("&#246;","Ã¶");
		CHAR_MAP.put("&ouml;","Ã¶");
		CHAR_MAP.put("&#247;","Ã·");
		CHAR_MAP.put("&divide;","Ã·");
		CHAR_MAP.put("&#248;","Ã¸");
		CHAR_MAP.put("&oslash;","Ã¸");
		CHAR_MAP.put("&#249;","Ã¹");
		CHAR_MAP.put("&ugrave;","Ã¹");
		CHAR_MAP.put("&#250;","Ãº");
		CHAR_MAP.put("&uacute;","Ãº");
		CHAR_MAP.put("&#251;","Ã»");
		CHAR_MAP.put("&ucirc;","Ã»");
		CHAR_MAP.put("&#252;","Ã¼");
		CHAR_MAP.put("&uuml;","Ã¼");
		CHAR_MAP.put("&#253;","Ã½");
		CHAR_MAP.put("&yacute;","Ã½");
		CHAR_MAP.put("&#254;","Ã¾");
		CHAR_MAP.put("&thorn;","Ã¾");
		CHAR_MAP.put("&#255;","Ã¿");
		CHAR_MAP.put("&yuml;","Ã¿");
		CHAR_MAP.put("&#338;","Å’"); 
		CHAR_MAP.put("&#339;","Å“"); 
		CHAR_MAP.put("&#352;","Å "); 
		CHAR_MAP.put("&#353;","Å¡"); 
		CHAR_MAP.put("&#376;","Å¸"); 
		CHAR_MAP.put("&#402;","Æ’"); 
		CHAR_MAP.put("&#8211;","â€“"); 
		CHAR_MAP.put("&#8212;","â€”"); 
		CHAR_MAP.put("&#8216;","â€˜"); 
		CHAR_MAP.put("&#8217;","â€™"); 
		CHAR_MAP.put("&#8218;","â€š"); 
		CHAR_MAP.put("&#8220;","â€œ"); 
		CHAR_MAP.put("&#8221;","â€�"); 
		CHAR_MAP.put("&#8222;","â€ž"); 
		CHAR_MAP.put("&#8224;","â€ "); 
		CHAR_MAP.put("&#8225;","â€¡"); 
		CHAR_MAP.put("&#8226;","â€¢"); 
		CHAR_MAP.put("&#8230;","â€¦"); 
		CHAR_MAP.put("&#8240;","â€°"); 
		CHAR_MAP.put("&#8364;","â‚¬");
		CHAR_MAP.put("&euro;","â‚¬");
		CHAR_MAP.put("&#8482;","â„¢"); 

		// replace all occurrences of all keys to their value
		for (Map.Entry<String, String> entry : CHAR_MAP.entrySet()) {
		    htmlToChange = htmlToChange.replaceAll(entry.getKey(), entry.getValue());
		}
		
		return(htmlToChange);
		
	}; 
	
} 
